package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.BankBillJd0028Mapper;
import com.xyy.saas.payment.dao.model.BankBillJd0028;
import com.xyy.saas.payment.dto.BankBillJd0028Total;
import com.xyy.saas.payment.service.BankBillSubmitPinganService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 京东账单数据上报平安
 *
 * @author chujian
 * @since 2023-06-13 15:06:34
 */
@Slf4j
@Service
public class BankBillJdSubmitPinganServiceImpl implements BankBillSubmitPinganService {
    @Resource
    private BankBillJd0028Mapper bankBillJd0028Mapper;

    /**
     * 京东账单上报平安 - 汇总信息
     */
    @Override
    public Map<String, BankBillJd0028Total> submitPinganTotal(String merchantNo, String billDate) {
        List<BankBillJd0028Total> bankBillJd0028Totals = bankBillJd0028Mapper.submitPinganTotal(merchantNo, billDate);
        if (CollectionUtils.isEmpty(bankBillJd0028Totals)) {
            return new HashMap<>();
        }
        Map<String, BankBillJd0028Total> res = new HashMap<>();
        for (BankBillJd0028Total bankBillJd0028Total : bankBillJd0028Totals) {
            res.put(bankBillJd0028Total.getOrderType(), bankBillJd0028Total);
        }
        return res;
    }

    /**
     * 京东账单上报平安 - 明细数据
     */
    @Override
    public List<BankBillJd0028> submitPinganDetail(String merchantNo, String billDate, Long id) {
        if (null == id) {
            id = 0L;
        }
        return bankBillJd0028Mapper.submitPinganDetail(merchantNo, billDate, id);
    }

}
